package com.nineclock.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nineclock.pojo.SysCompanyUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface SysCompanyUserMapper extends BaseMapper<SysCompanyUser> {
    // 查询当前企业管理员
    @Select("SELECT\n" +
            "scu.*\n" +
            "FROM\n" +
            "sys_company_user scu,\n" +
            "sys_company_user_role scur,\n" +
            "sys_role sr\n" +
            "WHERE\n" +
            "scu.id = scur.company_user_id\n" +
            "AND scur.role_id = sr.id\n" +
            "AND scu.company_id = #{companyId}\n" +
            "AND sr.role_name = 'ROLE_ADMIN_SYS'")
    SysCompanyUser findCompanyUserAdmin(@Param("companyId") Long companyId);
}
